import { Pipe, PipeTransform } from '@angular/core';
import { Product } from '../shared/product.service';

@Pipe({
  name: 'filter'
})
export class FilterPipe implements PipeTransform {

  transform(value: Product[], filterField: string, word: string): Product[] {
    if (!filterField || !word) {
      return value;
    }
    console.log(filterField,word);
    let rt = value.filter(item => {
      return item[filterField].indexOf(word) >= 0;
    });
    console.log(rt);
    return rt;
  }

}
